#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void findSolutions(int pos, long curr_val, long last_val, int num[], char expr[], int expr_len) {
    if (pos == 9) {  
        if (curr_val == 100) {
            expr[expr_len] = '\0'; 
            printf("%s = 100\n", expr); 
        }
        return;
    }

    int curr_num = num[pos];
    expr[expr_len] = '+';
    expr[expr_len + 1] = curr_num + '0';  
    findSolutions(pos + 1, curr_val + curr_num, curr_num, num, expr, expr_len + 2);
    expr[expr_len] = '-';
    expr[expr_len + 1] = curr_num + '0';
    findSolutions(pos + 1, curr_val - curr_num, -curr_num, num, expr, expr_len + 2);
    if (pos > 0) {
        expr[expr_len] = ' ';
        findSolutions(pos + 1, curr_val - last_val + (last_val * 10 + curr_num), last_val * 10 + curr_num, num, expr, expr_len + 1);
    }
}
int main() {
    int num[] = {9, 8, 7, 6, 5, 4, 3, 2, 1}; 
    char expr[20];  
    expr[0] = '9';  
    findSolutions(1, 9, 9, num, expr, 1); 
    return 0;
}

